<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button data-toggle-id="email">email</button>
    <div id="email">email: <input type="text" /></div>
    <hr />
    <span data-toggle-id="p1">haha</span>
    <p id="p1">hello haha</p>
    <script>
      // 复用
      document.addEventListener("click", function (e) {
        const target = e.target;
        const toggleId = target.dataset.toggleId;
        if (toggleId !== undefined) {
          // 找 id===toggleId 的元素对象
          const el = document.getElementById(toggleId);
          el.hidden = !el.hidden;
        }
      });
    </script>
  </body>
</html>
